package com.zenchn.dynamic;

import static com.zenchn.dynamic.TSysAccountDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TSysAccount;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TSysAccountDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    BasicColumn[] selectList = BasicColumn.columnList(accountId, createTime, account, password, status, realName, sex, tel, email, portraitFileId, postTypeId, isDefault, expireTime, memo, finalLoginIp, finalLoginTime, finalLoginLocation);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TSysAccount> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TSysAccount> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TSysAccountResult")
    Optional<TSysAccount> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TSysAccountResult", value = {
        @Result(column="account_id", property="accountId", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="account", property="account", jdbcType=JdbcType.VARCHAR),
        @Result(column="password", property="password", jdbcType=JdbcType.CHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="real_name", property="realName", jdbcType=JdbcType.VARCHAR),
        @Result(column="sex", property="sex", jdbcType=JdbcType.CHAR),
        @Result(column="tel", property="tel", jdbcType=JdbcType.VARCHAR),
        @Result(column="email", property="email", jdbcType=JdbcType.VARCHAR),
        @Result(column="portrait_file_id", property="portraitFileId", jdbcType=JdbcType.CHAR),
        @Result(column="post_type_id", property="postTypeId", jdbcType=JdbcType.CHAR),
        @Result(column="is_default", property="isDefault", jdbcType=JdbcType.BIT),
        @Result(column="expire_time", property="expireTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="memo", property="memo", jdbcType=JdbcType.VARCHAR),
        @Result(column="final_login_ip", property="finalLoginIp", jdbcType=JdbcType.VARCHAR),
        @Result(column="final_login_time", property="finalLoginTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="final_login_location", property="finalLoginLocation", jdbcType=JdbcType.VARCHAR)
    })
    List<TSysAccount> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TSysAccount, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TSysAccount, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    default int deleteByPrimaryKey(String accountId_) {
        return delete(c -> 
            c.where(accountId, isEqualTo(accountId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    default int insert(TSysAccount record) {
        return MyBatis3Utils.insert(this::insert, record, TSysAccount, c ->
            c.map(accountId).toProperty("accountId")
            .map(createTime).toProperty("createTime")
            .map(account).toProperty("account")
            .map(password).toProperty("password")
            .map(status).toProperty("status")
            .map(realName).toProperty("realName")
            .map(sex).toProperty("sex")
            .map(tel).toProperty("tel")
            .map(email).toProperty("email")
            .map(portraitFileId).toProperty("portraitFileId")
            .map(postTypeId).toProperty("postTypeId")
            .map(isDefault).toProperty("isDefault")
            .map(expireTime).toProperty("expireTime")
            .map(memo).toProperty("memo")
            .map(finalLoginIp).toProperty("finalLoginIp")
            .map(finalLoginTime).toProperty("finalLoginTime")
            .map(finalLoginLocation).toProperty("finalLoginLocation")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    default int insertMultiple(Collection<TSysAccount> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TSysAccount, c ->
            c.map(accountId).toProperty("accountId")
            .map(createTime).toProperty("createTime")
            .map(account).toProperty("account")
            .map(password).toProperty("password")
            .map(status).toProperty("status")
            .map(realName).toProperty("realName")
            .map(sex).toProperty("sex")
            .map(tel).toProperty("tel")
            .map(email).toProperty("email")
            .map(portraitFileId).toProperty("portraitFileId")
            .map(postTypeId).toProperty("postTypeId")
            .map(isDefault).toProperty("isDefault")
            .map(expireTime).toProperty("expireTime")
            .map(memo).toProperty("memo")
            .map(finalLoginIp).toProperty("finalLoginIp")
            .map(finalLoginTime).toProperty("finalLoginTime")
            .map(finalLoginLocation).toProperty("finalLoginLocation")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    default int insertSelective(TSysAccount record) {
        return MyBatis3Utils.insert(this::insert, record, TSysAccount, c ->
            c.map(accountId).toPropertyWhenPresent("accountId", record::getAccountId)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(account).toPropertyWhenPresent("account", record::getAccount)
            .map(password).toPropertyWhenPresent("password", record::getPassword)
            .map(status).toPropertyWhenPresent("status", record::getStatus)
            .map(realName).toPropertyWhenPresent("realName", record::getRealName)
            .map(sex).toPropertyWhenPresent("sex", record::getSex)
            .map(tel).toPropertyWhenPresent("tel", record::getTel)
            .map(email).toPropertyWhenPresent("email", record::getEmail)
            .map(portraitFileId).toPropertyWhenPresent("portraitFileId", record::getPortraitFileId)
            .map(postTypeId).toPropertyWhenPresent("postTypeId", record::getPostTypeId)
            .map(isDefault).toPropertyWhenPresent("isDefault", record::getIsDefault)
            .map(expireTime).toPropertyWhenPresent("expireTime", record::getExpireTime)
            .map(memo).toPropertyWhenPresent("memo", record::getMemo)
            .map(finalLoginIp).toPropertyWhenPresent("finalLoginIp", record::getFinalLoginIp)
            .map(finalLoginTime).toPropertyWhenPresent("finalLoginTime", record::getFinalLoginTime)
            .map(finalLoginLocation).toPropertyWhenPresent("finalLoginLocation", record::getFinalLoginLocation)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    default Optional<TSysAccount> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TSysAccount, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    default List<TSysAccount> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TSysAccount, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    default List<TSysAccount> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TSysAccount, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    default Optional<TSysAccount> selectByPrimaryKey(String accountId_) {
        return selectOne(c ->
            c.where(accountId, isEqualTo(accountId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TSysAccount, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    static UpdateDSL<UpdateModel> updateAllColumns(TSysAccount record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(accountId).equalTo(record::getAccountId)
                .set(createTime).equalTo(record::getCreateTime)
                .set(account).equalTo(record::getAccount)
                .set(password).equalTo(record::getPassword)
                .set(status).equalTo(record::getStatus)
                .set(realName).equalTo(record::getRealName)
                .set(sex).equalTo(record::getSex)
                .set(tel).equalTo(record::getTel)
                .set(email).equalTo(record::getEmail)
                .set(portraitFileId).equalTo(record::getPortraitFileId)
                .set(postTypeId).equalTo(record::getPostTypeId)
                .set(isDefault).equalTo(record::getIsDefault)
                .set(expireTime).equalTo(record::getExpireTime)
                .set(memo).equalTo(record::getMemo)
                .set(finalLoginIp).equalTo(record::getFinalLoginIp)
                .set(finalLoginTime).equalTo(record::getFinalLoginTime)
                .set(finalLoginLocation).equalTo(record::getFinalLoginLocation);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TSysAccount record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(accountId).equalToWhenPresent(record::getAccountId)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(account).equalToWhenPresent(record::getAccount)
                .set(password).equalToWhenPresent(record::getPassword)
                .set(status).equalToWhenPresent(record::getStatus)
                .set(realName).equalToWhenPresent(record::getRealName)
                .set(sex).equalToWhenPresent(record::getSex)
                .set(tel).equalToWhenPresent(record::getTel)
                .set(email).equalToWhenPresent(record::getEmail)
                .set(portraitFileId).equalToWhenPresent(record::getPortraitFileId)
                .set(postTypeId).equalToWhenPresent(record::getPostTypeId)
                .set(isDefault).equalToWhenPresent(record::getIsDefault)
                .set(expireTime).equalToWhenPresent(record::getExpireTime)
                .set(memo).equalToWhenPresent(record::getMemo)
                .set(finalLoginIp).equalToWhenPresent(record::getFinalLoginIp)
                .set(finalLoginTime).equalToWhenPresent(record::getFinalLoginTime)
                .set(finalLoginLocation).equalToWhenPresent(record::getFinalLoginLocation);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    default int updateByPrimaryKey(TSysAccount record) {
        return update(c ->
            c.set(createTime).equalTo(record::getCreateTime)
            .set(account).equalTo(record::getAccount)
            .set(password).equalTo(record::getPassword)
            .set(status).equalTo(record::getStatus)
            .set(realName).equalTo(record::getRealName)
            .set(sex).equalTo(record::getSex)
            .set(tel).equalTo(record::getTel)
            .set(email).equalTo(record::getEmail)
            .set(portraitFileId).equalTo(record::getPortraitFileId)
            .set(postTypeId).equalTo(record::getPostTypeId)
            .set(isDefault).equalTo(record::getIsDefault)
            .set(expireTime).equalTo(record::getExpireTime)
            .set(memo).equalTo(record::getMemo)
            .set(finalLoginIp).equalTo(record::getFinalLoginIp)
            .set(finalLoginTime).equalTo(record::getFinalLoginTime)
            .set(finalLoginLocation).equalTo(record::getFinalLoginLocation)
            .where(accountId, isEqualTo(record::getAccountId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_sys_account")
    default int updateByPrimaryKeySelective(TSysAccount record) {
        return update(c ->
            c.set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(account).equalToWhenPresent(record::getAccount)
            .set(password).equalToWhenPresent(record::getPassword)
            .set(status).equalToWhenPresent(record::getStatus)
            .set(realName).equalToWhenPresent(record::getRealName)
            .set(sex).equalToWhenPresent(record::getSex)
            .set(tel).equalToWhenPresent(record::getTel)
            .set(email).equalToWhenPresent(record::getEmail)
            .set(portraitFileId).equalToWhenPresent(record::getPortraitFileId)
            .set(postTypeId).equalToWhenPresent(record::getPostTypeId)
            .set(isDefault).equalToWhenPresent(record::getIsDefault)
            .set(expireTime).equalToWhenPresent(record::getExpireTime)
            .set(memo).equalToWhenPresent(record::getMemo)
            .set(finalLoginIp).equalToWhenPresent(record::getFinalLoginIp)
            .set(finalLoginTime).equalToWhenPresent(record::getFinalLoginTime)
            .set(finalLoginLocation).equalToWhenPresent(record::getFinalLoginLocation)
            .where(accountId, isEqualTo(record::getAccountId))
        );
    }
}